home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-05-03 | 2.8 KB | 90 lines | [TEXT/ALFA] |
- // This may look like C code, but it is really -*- C++ -*-
- /*
- ************************************************************************
- *
- * Grayscale Image
- * Generating Fractal Maps
- *
- * Declaration of a class of recursive subdivision, or plasma, fractals,
- * that generate self-similar images (with scaled noise).
- *
- * The fractal map is specified by its order, seeds, pixel depth, and
- * the random-number generating algorithm. The order is the only necessary
- * parameter, it specifies a square map (image) of dimension 2^order.
- * Order should be at least two (and not too large). There are reasonable
- * defaults for other parameters. Seeds are used to specify values
- * at the four corners of the map, map(0,0), map(2^order,0),
- * map(0,2^order) and map(2^order,2^order). Note, strictly speaking,
- * the seeds except map(0,0) are actually outside of the image itself.
- * The map isn't periodical, btw. The map points between the seeds
- * are filled in as an average of the corresponding boundary points
- * plus some random scaled noise. See "fractal_map.cc" for more
- * details about the implementation.
- *
- * Usage examples:
- * IMAGE map1 = FractalMap(9); // Use all the defaults
- * IMAGE map2 = FractalMap(9,Seeds(0,64,64,128));
- * class MyMap : public FractalMap
- * {
- * public:
- * int get_noise(const card scale) const { return your_random_number; }
- * MyMap(const card order) : FractalMap(order) {}
- * }
- * IMAGE map3 = MyMap(10); // Play with your own random number gen
- *
- * One may also want to blur/sharpen the fractal map afterwards (to make
- * it more appealing) by applying a corresponding filter, say, [1 1 1]
- *
- * Note, FractalMap is a LazyImage thing, that is, in
- * IMAGE map1 = FractalMap(9);
- * map construction is done "inplace" and *no* image is copied.
- *
- * $Id: fractal_map.h,v 2.0 1995/03/16 17:39:58 oleg Exp oleg $
- *
- ************************************************************************
- */
-
- #ifndef __GNUC__
- #pragma once
- #endif
- #ifndef _fractal_map_h
- #define _fractal_map_h
-
- #ifdef __GNUC__
- #pragma interface
- #endif
-
- #include "image.h"
-
- class FractalMap : public LazyImage
- {
- public:
- class Seeds
- {
- public:
- const GRAY s00, s10, s11, s01;
-
- Seeds(const GRAY seed)
- : s00(seed), s10(seed), s11(seed), s01(seed) {}
- Seeds(const GRAY ul, const GRAY ll, const GRAY ur, const GRAY lr)
- : s00(ul), s10(ll), s11(lr), s01(ur) {}
- };
- FractalMap(const card order, const Seeds& _seeds = Seeds(128),
- const card bits_per_pixel=8);
-
- // Get some noise with a dispersion 'scale'
- // (which is assumed to be a power of 2)
- // and average 0
- // Say, if scale=2 return either 0 or 1
- // if scale=128, return a random number
- // within [-64,63]
- virtual int get_noise(const card scale) const;
- private:
- Seeds seeds;
- void fill_in(IMAGE& im) const;
- };
-
- #endif
-
-
-